package com.winchain.chainbill.serfee.rx;

import com.shell.bee.acct.transaction.po.AcctTxRec;
import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.bill.base.po.CbDct;
import com.winchain.chainbill.bill.base.po.CbRec;
import com.winchain.chainbill.bill.biz.Bill;
import com.winchain.chainbill.bill.biz.BillEvent;
import com.winchain.chainbill.serfee.service.impl.ServiceFeeTranService;
import com.winchain.chainbill.trade.service.TradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillDctReAprvDeductSerFeeSubscriber extends OnErrorNotImplementedSubscriber<BillEvent<CbDct>> {
	@Autowired
	private TradeService tradeService;
	@Autowired
	private ServiceFeeTranService serviceFeeTranService;

	public void onApplicationEvent(BillEvent<CbDct> t) {
		CbRec rec = t.getBill().getRec();
		CbDct dct = (CbDct) t.getBill().getSource();
		AcctTxRec tran = this.serviceFeeTranService.getDeductSerFeeTran(rec, dct, "0");
		this.tradeService.callback(tran);
	}
}
